package com.ruoyi.finance.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.finance.mapper.IndustryMapper;
import com.ruoyi.finance.domain.Industry;
import com.ruoyi.finance.service.IIndustryService;

/**
 * 行业分类Service业务层处理
 *
 * @author ruoyi
 * @date 2025-02-24
 */
@Service
public class IndustryServiceImpl extends ServiceImpl<IndustryMapper, Industry> implements IIndustryService
{
    @Autowired
    private IndustryMapper industryMapper;

    /**
     * 查询行业分类
     *
     * @param industryId 行业分类主键
     * @return 行业分类
     */
    @Override
    public Industry selectIndustryByIndustryId(Long industryId)
    {
        return industryMapper.selectIndustryByIndustryId(industryId);
    }

    /**
     * 查询行业分类列表
     *
     * @param industry 行业分类
     * @return 行业分类
     */
    @Override
    public List<Industry> selectIndustryList(Industry industry)
    {
        return industryMapper.selectIndustryList(industry);
    }

    /**
     * 新增行业分类
     *
     * @param industry 行业分类
     * @return 结果
     */
    @Override
    public int insertIndustry(Industry industry)
    {
        List<Industry> list = lambdaQuery().eq(Industry::getIndustryName, industry.getIndustryName()).list();
        if(list!=null&&list.size()>0){
            throw new RuntimeException("行业分类名称已存在");
        }
        return industryMapper.insert(industry);
    }

    /**
     * 修改行业分类
     *
     * @param industry 行业分类
     * @return 结果
     */
    @Override
    public int updateIndustry(Industry industry)
    {
        return industryMapper.updateIndustry(industry);
    }

    /**
     * 批量删除行业分类
     *
     * @param industryIds 需要删除的行业分类主键
     * @return 结果
     */
    @Override
    public int deleteIndustryByIndustryIds(Long[] industryIds)
    {
        return industryMapper.deleteIndustryByIndustryIds(industryIds);
    }

    /**
     * 删除行业分类信息
     *
     * @param industryId 行业分类主键
     * @return 结果
     */
    @Override
    public int deleteIndustryByIndustryId(Long industryId)
    {
        return industryMapper.deleteIndustryByIndustryId(industryId);
    }
}
